package com.ricchieri.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.springframework.cache.annotation.Cacheable;

import com.ricchieri.dao.interf.IMeanPaymentDao;
import com.ricchieri.filter.BasicFilter;
import com.ricchieri.model.MeanPayment;

public class MeanPaymentDao extends GenericDao implements IMeanPaymentDao {
	private static final long serialVersionUID = -3672053965375215277L;

	@Override
	@Cacheable(value="meanPayment")
	@SuppressWarnings("unchecked")
	public List<MeanPayment> getAllMeanPayment(BasicFilter filter) {
		Criteria criteria = criteriaAllMeanPayment(filter);
		
		return criteria.list();
	}
	
	private Criteria criteriaAllMeanPayment(BasicFilter filter) {
		return super.criteriaAllBasic(filter, MeanPayment.class);
	}	
	
	@Override
	protected String getTableName() {
		return "meanPayment";
	}

	@Override
	public MeanPayment getMeanPaymentById(BasicFilter meanPaymentFilter) {
		Criteria criteria = criteriaAllMeanPayment(meanPaymentFilter);
		
		return (MeanPayment) criteria.list().get(0);
	}
}
